﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BaiTu.Framework.MVCFramework.Helper
{
    public static class TypeCastHelper
    {
        public static object Cast(string source, Type toType)
        {
            if (toType.Equals(typeof(int)))
                return int.Parse(source);

            if (toType.Equals(typeof(long)))
                return long.Parse(source);

            if (toType.Equals(typeof(Guid)))
                return new Guid(source);

            if (toType.Equals(typeof(string)))
                return source;

            return null;
        }
    }
}
